package com.adv.ems.model.vo;

import com.adv.ems.db.entity.*;
import com.adv.ems.enums.SubjectTypeEnum;
import com.adv.ems.utils.EmsUtil;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;

@Data
public class EnergySearchSubjectTreeVO {
    private List<Node> list;

    public EnergySearchSubjectTreeVO() {
        list = new ArrayList<Node>();
    }

    @Data
    public static class Node {
        private Long id;
        private String label;
        private SubjectTypeEnum type;
        private List<Node> children;

        public Node() {
            this.children = new ArrayList<Node>();
        }

        public Node(InstituteInfoDO instituteInfoDO, String acceptLanguage) {
            this.id = instituteInfoDO.getId();
            this.label = EmsUtil.getNameInfo(instituteInfoDO.getNameInfo(), acceptLanguage).getShortName();
            this.type = SubjectTypeEnum.INSTITUTE;
            this.children = new ArrayList<Node>();
        }

        public Node(BuildingInfoDO buildingInfoDO, String acceptLanguage) {
            this.id = buildingInfoDO.getId();
            this.label = EmsUtil.getNameInfo(buildingInfoDO.getNameInfo(), acceptLanguage).getShortName();
            this.type = SubjectTypeEnum.BUILDING;
            this.children = new ArrayList<Node>();
        }

        public Node(DepartmentInfoDO departmentInfoDO, String acceptLanguage) {
            this.id = departmentInfoDO.getId();
            this.label = EmsUtil.getNameInfo(departmentInfoDO.getNameInfo(), acceptLanguage).getShortName();
            this.type = SubjectTypeEnum.DEPARTMENT;
            this.children = new ArrayList<Node>();
        }

        public Node(GatewayDeviceDO gatewayDeviceDO, String acceptLanguage) {
            this.id = gatewayDeviceDO.getId();
            this.label = gatewayDeviceDO.getName();
            this.type = SubjectTypeEnum.GATEWAY;
            this.children = new ArrayList<Node>();
        }

        public Node(MeterDO meterDO, String acceptLanguage) {
            this.id = meterDO.getId();
            this.label = meterDO.getName();
            this.type = SubjectTypeEnum.METER;
            this.children = new ArrayList<Node>();
        }

        public Node(CollectPointDO pointDO, String acceptLanguage) {
            this.id = pointDO.getId();
            this.label = pointDO.getName();
            this.type = SubjectTypeEnum.POINT;
            this.children = new ArrayList<Node>();
        }
    }
}
